for a in range(1, 10):
    for b in range(1, 10):
        if b == a: continue  # 剪枝
        for c in range(1, 10):
            if c == a or c == b: continue
            for d in range(1, 10):
                if d in [a, b, c]: continue
                for e in range(1, 10):
                    if e in [a, b, c, d]: continue
                    for f in range(1, 10):
                        if f in [a, b, c, d, e]: continue
                        for g in range(1, 10):
                            if g in [a, b, c, d, e, f]: continue
                            for h in range(1, 10):
                                if h in [a, b, c, d, e, f, g]: continue
                                i = 45 - a - b - c - d - e - f - g - h
                                if a + b + c != 15: continue
                                if d + e + f != 15: continue
                                if g + h + i != 15: continue
                                if a + d + g != 15: continue
                                if b + e + h != 15: continue
                                if c + f + i != 15: continue
                                if a + e + i != 15: continue
                                if c + e + g != 15: continue

                                print(a, b, c)
                                print(d, e, f)
                                print(g, h, i)
                                print()
